% selection function gambal wheel
function sel = Selection(fitvalue)
fitness = fitvalue / sum(fitvalue);
rows = size(fitness,1);
sp = cumsum(fitness);
rp = rand(rows,1); % random number between 0~1 (uniform distribution)
rp = sort(rp);
sel = zeros(rows,1);
t = 1;
for i = 1 : rows
    while t <= rows
        if(rp(i) < sp(t))
            sel(t,1) = sel(t,1) + 1;
            break;
        else
            t = t + 1;
        end
    end
end
